home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / mxlibs / dwstk102 / findsb.pas < prev    next >
Pascal/Delphi Source File  |  1995-04-12  |  4KB  |  154 lines

  1. (******************************************************************************
  2. File:                          findsb.pas 1.02
  3. Tab stops:                 every 2 columns
  4. Project:                     FINDSB utility
  5. Copyright:                 1994-1995 DiamondWare, Ltd.    All rights reserved.
  6. Written:                     Keith Weiner & Erik Lorenzen
  7. Pascal Conversion: David A. Johndrow
  8. Purpose:           Example code to autodetect and print out the sound hardware
  9. History:                     94/10/21 KW Started
  10.                                      94/11/11 DJ Converted
  11.                                      95/02/02 EL Cleaned up & Finalized
  12.                                      95/03/22 EL Finalized for 1.01
  13.                                      95/04/11 EL Finalized for 1.02
  14. ******************************************************************************)
  15.  
  16.  
  17.  
  18. Program FindSb;
  19.  
  20. uses crt, err, dws;
  21.  
  22.  
  23.  
  24. Var
  25.     dov:    dws_DOPTR;
  26.     dres: dws_DRPTR;
  27.  
  28.  
  29.  
  30. Function HVal(i: word): char;
  31. begin
  32.     if (i < 10) then
  33.     begin
  34.         HVal := chr(i+48);
  35.     end
  36.     else
  37.     begin
  38.         HVal := chr(i+55);
  39.     end;
  40. end;
  41.  
  42.  
  43. Function HexStr(d: word): string;
  44. Var
  45.     s: string;
  46.  
  47. begin
  48.     s := '    ';
  49.  
  50.     s[4] := HVal(d mod 16);
  51.     s[3] := HVal((d div 16) mod 16);
  52.     s[2] := HVal((d div 256) mod 16);
  53.     s[1] := HVal((d div 4096) mod 16);
  54.  
  55.     while (s[1] = '0') and (length(s) > 1) do
  56.     begin
  57.         Delete(s,1,1);
  58.     end;
  59.  
  60.     HexStr := s;
  61. end;
  62.  
  63.  
  64.  
  65. begin
  66.     writeln;
  67.     writeln('FINDSB 1.02 is Copyright 1994-95, DiamondWare, Ltd.');
  68.     writeln('All rights reserved.');
  69.     writeln;
  70.     writeln;
  71.  
  72.     new(dov);
  73.     new(dres);
  74.  
  75.     (*
  76.      . We need to set every field to -1 (65635) in dws_DETECTOVERRIDES struct;
  77.      . this tells the STK to autodetect everything.  Any other value
  78.      . overrides the autodetect routine, and will be accepted on
  79.      . faith, though the STK will verify it if possible.
  80.     *)
  81.     dov^.baseport := 65535;
  82.     dov^.digdma     := 65535;
  83.     dov^.digirq     := 65535;
  84.  
  85.     if (dws_DetectHardWare(dov, dres) = 0) then
  86.     begin
  87.         err_Display;
  88.         halt(65535);
  89.     end;
  90.  
  91.  
  92.     if (((dres^.capability and dws_capability_FM) = dws_capability_FM) or
  93.             ((dres^.baseport <> 904) and (dres^.baseport <> 65535))) then
  94.     begin
  95.         writeln('Base port is ',HexStr(dres^.baseport),' hex');
  96.         writeln('');
  97.  
  98.         if (dres^.mixtyp <> 1) then
  99.         begin
  100.             writeln('The sound hardware supports mixing.');
  101.             writeln('');
  102.         end
  103.         else
  104.         begin
  105.             writeln('Mixing will be done in software.');
  106.             writeln('');
  107.         end;
  108.  
  109.         if ((dres^.capability and dws_capability_FM) = dws_capability_FM) then
  110.         begin
  111.             writeln('The sound hardware supports FM music playback.');
  112.             writeln;
  113.         end
  114.         else
  115.         begin
  116.             writeln('Support for FM music playback not found.');
  117.             writeln('');
  118.         end;
  119.  
  120.         if ((dres^.capability and dws_capability_DIG) = dws_capability_DIG) then
  121.         begin
  122.             (* If we got here dws_DetectHardWare got PORT, IRQ, & DMA *)
  123.             writeln('The sound hardware supports digitized sound playback.');
  124.             writeln('The sound hardware uses DMA channel ',dres^.digdma,' and IRQ level ',dres^.digirq,'.');
  125.             writeln;
  126.         end
  127.         else if ((dres^.baseport <> 904) and (dres^.baseport <> 65535)) then
  128.         begin
  129.             (*
  130.              . If dres.baseport isn't either 388hex, or -1, then it's a valid
  131.              . baseport.    So if we got here, then we didn't find either IRQ
  132.              . level, and/or DMA channel.  In order to play digitized sounds,
  133.              . we need these settings as well.    In your application, you should
  134.              . ask the user.
  135.             *)
  136.             writeln('The sound hardware supports digitized sound playback,');
  137.             writeln('but we could not find the DMA channel and/or IRQ level.');
  138.  
  139.         end
  140.         else
  141.         begin
  142.             writeln('Support for digitized playback not found.');
  143.             writeln('');
  144.         end;
  145.  
  146.     end
  147.     else
  148.     begin
  149.         writeln('No sound hardware detected.');
  150.         writeln;
  151.     end;
  152.  
  153. end.
  154.